﻿/*
 * 
 * User: manju  Date: 8/2/2012
 * 
 */
using System;
using System.Web.Mvc;
using Forums.Domain;
using Forums.Data;
 
namespace MVCForumApp.Controllers
{
	public class HomeController : Controller
	{
		IUserDao userDao = new UserDaoPGImpl ();
		public ActionResult Index()
		{
			return View();
		}
		
		public ActionResult Contact()
		{
			return View();
		}
		

		public ActionResult  Create(FormCollection Collection)
		{
			try
			{
				User u = new User();
				if(ModelState.IsValid)
				{
					
					u.UserName  = Collection["username"].ToString();
					u.UserPwd = Collection ["pwd"].ToString();
					u.FirstName = Collection ["fname"].ToString();
					u.LastName =Collection ["lname"].ToString();
					u.Email=Collection ["emailadd"].ToString();
					u.City =Collection ["city"].ToString();
					u.Country = Collection ["Country"].ToString();
					u.TimezoneCode =Collection ["timezoneoffset"].ToString();
					userDao.SaveorUpadateUser(u);
					return RedirectToAction("Index");
				}
				else 
					return View("Contact");
				
			}
			
			catch(Exception ex)
			{
        	 return View();
        	}
			
		
		}
		
        
        	   
        	  
//            if (!TryUpdateModel(um)) {
//                ViewBag.updateError = "Create Failure";
//                return View(um);
//            }
//
//            // ToDo: add persistent to DB.
//            
//            User u = new User();
//            userDao.SaveorUpadateUser(u);
//            .Create(um);
//            return View("Details", um);
       
	}}
	

